package Swing.src.landlord;

import java.util.ArrayList;
import java.util.Collections;
import java.util.TreeMap;
import java.util.TreeSet;

public class PlayGame {
    //拿牌
//洗牌
//发牌
//看牌
    //序号
    static ArrayList<Integer> list = new ArrayList<>();
    static TreeMap<Integer, String> treeMap = new TreeMap<>();

    static {
        String[] color = {"♦", "❤", "♣", "♠"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        int searchNum = 1;
        for (String n : number) {
            for (String c : color) {
                treeMap.put(searchNum, c + n);
                list.add(searchNum);
                searchNum++;
            }
        }
        treeMap.put(searchNum, "小王");
        list.add(searchNum);
        searchNum++;
        treeMap.put(searchNum, "大王");
        list.add(searchNum);
    }

    PlayGame() {
        Collections.shuffle(list);
        TreeSet<Integer> load = new TreeSet<>();
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            if (i <= 2) {
                load.add(list.get(i));
            } else if (i % 3 == 0) {
                player1.add(list.get(i));
            } else if (i % 3 == 1) {
                player2.add(list.get(i));
            } else if (i % 3 == 2) {
                player3.add(list.get(i));
            }
        }

        lookPlayer("蔡徐坤", player1);
        lookPlayer("丁真", player2);
        lookPlayer("肖战", player3);
        lookPlayer("底牌", load);
    }

    public void lookPlayer(String name, TreeSet<Integer> st) {
        System.out.print(name + ":");
        for (Integer searchNum : st) {
            System.out.print(treeMap.get(searchNum) + ' ');
        }
        System.out.println();
    }
}
